﻿<Window x:Class="AmazonGlacierGUI.UI.Views.DownloadArchiveByArchiveId"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:System="clr-namespace:System;assembly=mscorlib"
        xmlns:AmazonGlacier="clr-namespace:AmazonGlacierGUI.Core.Helpers.AmazonGlacier;assembly=AmazonGlacierGUI.Core"
        xmlns:FWControls="clr-namespace:AmazonGlacierGUI.UI.Infrastructure.MVVMFramework.Controls"
        Title="Download archive" Height="320" Width="735" WindowStartupLocation="CenterScreen" ResizeMode="CanResize" Loaded="Window_Loaded">
    <Window.Resources>
        <ObjectDataProvider x:Key="regionEnum"
       MethodName="GetValues" ObjectType="{x:Type System:Enum}">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="AmazonGlacier:AmazonRegionEnum"/>
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
    </Window.Resources>
    <Grid Margin="5">

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
        </Grid.RowDefinitions>
        <FWControls:ValidationSummary Grid.Row="0" Margin="0,5,0,5" ></FWControls:ValidationSummary>
        <StackPanel Grid.Row="1">

            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition  Height="20"></RowDefinition>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="150"></ColumnDefinition>
                    <ColumnDefinition></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Row="0" Grid.Column="0" Text="Save to"></TextBlock>
                <StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal">
                    <TextBox Width="348" TextWrapping="NoWrap" Text="{Binding SaveToPath,Mode=TwoWay,ValidatesOnDataErrors=True,NotifyOnValidationError=True}"></TextBox>
                    <Button Content="Browse" Height="21" Width="43" Command="{Binding BrowseFolderCommand}"></Button>
                </StackPanel>
            </Grid>
            <Grid  Margin="0,5,0,0">
                <Grid.RowDefinitions>
                    <RowDefinition  Height="20"></RowDefinition>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="150"></ColumnDefinition>
                    <ColumnDefinition></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Row="0" Grid.Column="0" Text="Region"></TextBlock>
                <ComboBox Grid.Column="1" ItemsSource="{Binding Source={StaticResource regionEnum}}"
                          SelectedItem="{Binding Region,Mode=TwoWay,ValidatesOnDataErrors=True,NotifyOnValidationError=True}" Margin="0,0,3,0" Width="348" HorizontalAlignment="Left"></ComboBox>
            </Grid>
            <Grid Margin="0,5,0,0">
                <Grid.RowDefinitions>
                    <RowDefinition  Height="20"></RowDefinition>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="150"></ColumnDefinition>
                    <ColumnDefinition></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Row="0" Grid.Column="0" Text="Vault name"></TextBlock>
                <StackPanel Grid.Row="0" Grid.Column="1"  Orientation="Horizontal">
                    <TextBox  Text="{Binding VaultName,Mode=TwoWay,ValidatesOnDataErrors=True,NotifyOnValidationError=True}" Width="348" HorizontalAlignment="Left"></TextBox>
                    <Button Content="Browse" Height="21" Width="43" Command="{Binding BrowseVaultCommand}"></Button>
                </StackPanel>
            </Grid>

            <TextBlock Text="Loading.." Visibility="{Binding IsLoading,Converter={StaticResource BooleanToVisibilityConverter}}" Margin="0,5,0,0"></TextBlock>
        </StackPanel>
        <DockPanel    Margin="0,5,0,0" Grid.Row="2">
            <DataGrid x:Name="dg" Grid.Row="1" AutoGenerateColumns="False" ItemsSource="{Binding ArchiveDetails}"
                  Margin="0,5,0,0"  CanUserAddRows="True" CanUserDeleteRows="True" >
                <DataGrid.Columns>
                    <!--<DataGridTemplateColumn Header="Archive Id" CanUserResize="False">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBox Text="{Binding ArchiveId,Mode=TwoWay,ValidatesOnDataErrors=True,NotifyOnValidationError=True,UpdateSourceTrigger=LostFocus}"></TextBox>                                    
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>                            
                            <DataGridTemplateColumn Header="Save as file name" Width="200">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBox Text="{Binding SaveAsFileName,Mode=TwoWay,ValidatesOnDataErrors=True,NotifyOnValidationError=True,UpdateSourceTrigger=LostFocus}"></TextBox>
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>-->
                    <DataGridTextColumn Header="Archive Id"  Binding="{Binding ArchiveId,Mode=TwoWay,ValidatesOnDataErrors=True,NotifyOnValidationError=True}"></DataGridTextColumn>
                    <DataGridTextColumn Header="Save as file name"  Binding="{Binding SaveAsFileName,Mode=TwoWay,ValidatesOnDataErrors=True,NotifyOnValidationError=True}"></DataGridTextColumn>

                </DataGrid.Columns>
            </DataGrid>
        </DockPanel>

        <StackPanel Orientation="Horizontal" Margin="150,10,0,0" Grid.Row="3">
            <Button Content="Download"  Height="22" Width="80" VerticalAlignment="Top"  HorizontalAlignment="Left" Command="{Binding DownloadCommand}"></Button>
            <Button Content="Close"  Height="22" Width="80" Margin="5,0,0,0" VerticalAlignment="Top"  HorizontalAlignment="Left" Command="{Binding CloseCommand}"></Button>
        </StackPanel>

    </Grid>

</Window>
